package net.zjitc.myInterceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import net.zjitc.damain.Admin.Admin;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2017/3/13.
 */
@Component
public class AdminInterceptor implements Interceptor {
    @Override
    public void destroy() {

    }

    @Override
    public void init() {

    }

    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        Admin admin = (Admin) ActionContext.getContext().getSession().get("admin");
        if (admin == null ){
            return "nologin";
        }else {
            //如果已登录，放行
            return actionInvocation.invoke();
        }
    }
}
